//
//  RNIOSAlert.m
//  liveNativeRN
//
//  Created by 李玉臣 on 2018/4/27.
//  Copyright © 2018年 Facebook. All rights reserved.
//

#import "RNIOSAlertBridgeModule.h"
#import <React/RCTConvert.h>
#import <React/RCTUtils.h>

@implementation RNIOSAlertBridgeModule

RCT_EXPORT_MODULE(RNIOSAlertBridgeModule);

// 一个参数
RCT_EXPORT_METHOD(show:(NSString *)msg){
  RCTExecuteOnMainQueue(^{
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:msg delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alertView show];
  });
}
// 两个参数
RCT_EXPORT_METHOD(showName:(NSString *)name gender:(NSString *)gender){

  RCTExecuteOnMainQueue(^{
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:name message:gender delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alertView show];
  });
}
// 字典对象
RCT_EXPORT_METHOD(bringSomethingName:(NSString *)name details:(NSDictionary *)details){
  NSString * merchant = [RCTConvert NSString:details[@"merchant"]];
  NSString * price = [RCTConvert NSString:details[@"price"]];
  NSLog(@"%@", merchant);
  NSLog(@"%@", price);
}
// 回调函数 返回值
RCT_EXPORT_METHOD(buySomething:(RCTResponseSenderBlock)callBack){

  NSDictionary *dict = @{@"clothes": @"semir", @"shoes" : @"Nike", @"food": @"banana"};
  callBack(@[[NSNull null],dict]);
}
@end
